package com.itheima.d3ExceptionDemo;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            try {
                System.out.println("输入价格：");
                String nextLine = sc.next();
                double price = Double.parseDouble(nextLine);
                if (price > 0) {
                    System.out.println("定价:" + price);
                    break;
                } else {
                    System.out.println("输入有误");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
